<template>
	<view>
		<view :data-theme="theme">
			<form report-submit='true'>
				<view class='merchantsSettled'>
					<view class='list' style="padding-bottom: 10px;">
						<view v-if="merchantData.type==4" class="item" style="color: red; margin-bottom: 20rpx;">
							<text class="item-name">审核拒绝原因:{{merchantData.failMsg}}</text>
						</view>
						
						<view class="item" style="margin-bottom: 20rpx;">
							<view class="required" >
								<text class="item-name">开户类型</text>
								<view style="flex: 1;text-align: right;">
									<picker
									mode="selector"
									@change="bindPickerType" 
									:value="shopApplyTypeIndex" 
									:range="shopApplyType" 
									range-key="name">
										<view>{{shopApplyTypeName}}</view>
									</picker>
								</view>
								<view class='iconfont icon-xiangyou'></view>
							</view>
						</view>
						
						<view>
							<view class="item">
								<view class="acea-row row-middle required">
									<text class="item-name">商户名称</text>
									<input type="text" maxlength="30" placeholder="商户名称" v-model="merchantData.mercName" 
									 placeholder-class='placeholder' />
								</view>
							</view>
							<view v-if="merchantData.mercName!=null&&merchantData.mercName.length>=20" class="item">
								<view class="required">
									<text class="item-name">商户简称</text>
									<input type="text" maxlength="20" placeholder="商户简称" v-model="merchantData.mercShortName" 
									 placeholder-class='placeholder' />
								</view>
							</view>
							<view class="item" style="margin-top: 20rpx;">
								<view class="required">
									<text class="item-name">营业执照名称</text>
									<input type="text" placeholder="营业执照名称" v-model="merchantData.busNm" 
									 placeholder-class='placeholder' />
								</view>
							</view>
							<view class="item">
								<view class="required">
									<text class="item-name">统一社会信用代码</text>
									<input type="text" placeholder="统一社会信用代码" v-model="merchantData.busNo" 
									 placeholder-class='placeholder' />
								</view>
							</view>
							<view class="item">
								<view class="required">
									<text class="item-name">营业执照有效期开始</text>
									<view style="flex: 1;text-align: right;">
										<picker 
										mode="date" 
										:start="startDate" 
										:end="endDate"  
										@change="bindPickerBusBgn">
											<view>{{busCertBgn}}</view>
										</picker>
									</view>
									<view class='iconfont icon-xiangyou'></view>
								</view>
							</view>
							<view class="item">
								<view class="required">
									<text class="item-name">营业执照有效期结束</text>
									<view style="flex: 1;text-align: right;">
										<picker  
										mode="selector"
										@change="bindPickerBusEnd" 
										:range="busDate" 
										range-key="name">
											<view>{{busCertExpire}}</view>
										</picker>
									</view>
									<view class='iconfont icon-xiangyou'></view>
								</view>
							</view>
							<view class="item" style="margin-top: 20rpx;">
								<view class="required">
									<text class="item-name">店铺类型</text>
									<view style="flex: 1;text-align: right;" @click="ysTypeShow=true">{{merchantData.mercClsNm==null?"请选择":merchantData.mercClsNm}}</view>
									<view class='iconfont icon-xiangyou'></view>
								</view>
							</view>
							<view class="item" style="margin-top: 20rpx;">
								<view class="required">
									<text class="item-name">联系人姓名</text>
									<input type="text" placeholder="联系人姓名" v-model="merchantData.contactMan" 
									 placeholder-class='placeholder' />
								</view>
							</view>
						</view>		
						<view class="item">
							<view class=" required">
								<text class="item-name">联系人电话</text>
								<input type="number"  placeholder="联系人电话" v-model="merchantData.contactPhone" 
								 placeholder-class='placeholder' />
							</view>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">营业地址</text>
								<view style="flex: 1; text-align: right;" @click="ysRegionShow=addressShow=true">{{addressStr}}</view>
								<view class='iconfont icon-xiangyou'></view>
							</view>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">详细地址</text>
								<input type="text" class="texts" v-model="merchantData.busAddr" placeholder="详细地址" />
								<view class='iconfont icon-dizhi' @click="goToMap"></view>
							</view>
						</view>
						
						<view class="item" style="margin-top: 20rpx;">
							<view class="required">
								<text class="item-name">法人身份证姓名</text>
								<input :disabled="disabled" type="text" placeholder='法人身份证姓名'
								v-model="merchantData.crpNm" placeholder-class='placeholder' />
							</view>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">法人身份证号码</text>
								<input type="number" placeholder="法人身份证号码" 
								v-model="merchantData.crpCertNo" placeholder-class='placeholder' />
							</view>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">法人身份证有效期开始</text>
								<view style="flex: 1;text-align: right;">
									<picker
									mode="date" 
									:start="startDate" 
									:end="endDate"  
									@change="bindPickerBgn">
										<view>{{certBgn}}</view>
									</picker>
								</view>
								<view class='iconfont icon-xiangyou'></view>
							</view>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">法人身份证有效期结束</text>
								<view style="flex: 1;text-align: right;">
									<picker
									mode="selector"
									@change="bindPickerEnd" 
									:range="certDate" 
									range-key="name">
										<view>{{certExpire}}</view>
									</picker>
								</view>
								<view class='iconfont icon-xiangyou'></view>
							</view>
						</view>
						<view class="item" style="margin-top: 20rpx;">
							<text class="item-desc">提示：银行卡号输入完毕后，请点击右侧按钮校验银行卡信息</text>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">银行卡开户地址</text>
								<view style="flex: 1;text-align: right;" @click="ysRegionShow=true">{{merchantData.bankAddress==null?"请选择":merchantData.bankAddress}}</view>
								<view class='iconfont icon-xiangyou'></view>
							</view>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">结算户名</text>
								<input type="text" class="texts" v-model="merchantData.stlAccNm" placeholder="结算户名" />
							</view>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">银行卡号</text>
								<input type="number" class="texts" v-model="merchantData.stlAccNo" placeholder="银行卡号"  style="width: 400rpx;"/>
								<view class="checkBtn" @click="checkBankNo">校验</view>
							</view>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">银行名称</text>
								<input disabled="true" type="text" class="texts" v-model="merchantData.bank" placeholder="银行名称" />
							</view>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">支行名称</text>
								<input disabled="true" type="text" class="texts" v-model="merchantData.bankSubName" placeholder="支行名称" />
							</view>
						</view>
						<view class="item">
							<view class="required">
								<text class="item-name">结算账户类型</text>
								<view style="flex: 1; text-align: right;">
									<picker
									mode="selector"
									@change="bindPickerStlAccType" 
									:range="accTypes" 
									range-key="name">
										<view>{{stlAccTypeNm}}</view>
									</picker>
								</view>
								<view class='iconfont icon-xiangyou'></view>
							</view>
						</view>
						<view class="item no-border acea-row row-center" style="margin-top: 20rpx;">
							<checkbox-group class="acea-row" style="align-items: end;">
								<checkbox class="checkbox" :checked="uncrpSett" @click="uncrpSett=!uncrpSett"/>
								<span>非法人结算</span>
							</checkbox-group>
						</view>
						<view v-if="uncrpSett">
							<view class="item">
								<view class="required">
									<text class="item-name">银行预留手机号</text>
									<input type="number" class="texts" v-model="merchantData.bankMobile" placeholder="银行预留手机号" />
								</view>
							</view>
							<view class="item">
								<view class="required">
									<text class="item-name">开户证件号</text>
									<input type="number" class="texts" v-model="merchantData.openCertNo" placeholder="开户证件号" />
								</view>
							</view>
							<view class="item">
								<view class="required">
									<text class="item-name">备用结算户名</text>
									<input type="text" class="texts" v-model="merchantData.standByStlAccNm" placeholder="备用结算户名" />
								</view>
							</view>
							<view class="item">
								<view class="required">
									<text class="item-name">结算行地址</text>
									<view style="flex: 1; text-align: right;" @click="ysRegionShow=standByShow=true">{{merchantData.standByBankAddress==null?"请选择":merchantData.standByBankAddress}}</view>
									<view class='iconfont icon-xiangyou'></view>
								</view>
							</view>
							<view class="item">
								<view class="required">
									<text class="item-name">备用结算账号</text>
									<input type="number" class="texts" v-model="merchantData.standByStlAccNo" placeholder="备用结算账号" />
									<view class="checkBtn" @click="checkStandBankNo">校验</view>
								</view>
							</view>
							<view class="item">
								<view class="required">
									<text class="item-name">备用结算行名称</text>
									<input disabled="true" type="number" class="texts" v-model="merchantData.standByBank" placeholder="备用结算行名称" />
								</view>
							</view>
							<view class="item">
								<view class="required">
									<text class="item-name">备用支行名称</text>
									<input disabled="true" type="number" class="texts" v-model="merchantData.standByBankName" placeholder="备用支行名称" />
								</view>
							</view>
							<view class="item">
								<view class="required">
									<text class="item-name">备用结算账户类型</text>
									<view style="flex: 1; text-align: right;">
										<picker
										mode="selector"
										@change="bindPickerStandByStlAccType" 
										:range="accTypes" 
										range-key="name">
											<view>{{standByStlAccTypeNm}}</view>
										</picker>
									</view>
									<view class='iconfont icon-xiangyou'></view>
								</view>
							</view>
						</view>
						<button class='submitBtn' @click="formSubmit">下一步</button>
					</view>
				</view>
			</form>
			<view class='loadingicon acea-row row-center-wrapper' v-if="loading">
				<text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>
			</view>
		</view>
		
		<view v-if="ysRegionShow" @click="ysRegionShow=false">
			<view class="staorder-overlay"></view>
			<view class="pickerBtn">
				<view @click="ysRegionShow=false">取消</view>
				<view class="sure" @click="checkYsRegion">确定</view>
			</view>
			<picker-view :value="ysIndex" @change="bindChangeYsRegion" class="picker-view">
				<picker-view-column>
					<view class="item" v-for="(item,index) in ysProvince" :key="index">{{item.cityNm}}</view>
				</picker-view-column>
				<picker-view-column>
					<view class="item" v-for="(item,index) in ysCity" :key="index">{{item.cityNm}}</view>
				</picker-view-column>
				<picker-view-column>
					<view class="item" v-for="(item,index) in ysArea" :key="index">{{item.cityNm}}</view>
				</picker-view-column>
			</picker-view>
		</view>
		
		<view v-if="ysTypeShow" @click="ysTypeShow=false">
			<view class="staorder-overlay"></view>
			<view class="pickerBtn">
				<view @click="ysTypeShow=false">取消</view>
				<view class="sure" @click="checkYsType">确定</view>
			</view>
			<picker-view :value="value" @change="bindChangeYsType" class="picker-view">
				<picker-view-column>
					<view class="item" v-for="(item,index) in ysChannelList" :key="index">{{item.name}}</view>
				</picker-view-column>
				<picker-view-column>
					<view class="item" v-for="(item,index) in ysCategoryList" :key="index">{{item.firstCategory.categoryName}}</view>
				</picker-view-column>
			</picker-view>
		</view>
	</view>
</template>
<script>
	// +----------------------------------------------------------------------
	// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
	// +----------------------------------------------------------------------
	// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
	// +----------------------------------------------------------------------
	// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
	// +----------------------------------------------------------------------
	// | Author: CRMEB Team <admin@crmeb.com>
	// +----------------------------------------------------------------------
	import { toLogin } from '@/libs/login.js';
	import Cache from '@/utils/cache';
	import { mapGetters } from "vuex";
	import parser from "../components/jyf-parser/jyf-parser";
	import { Debounce } from '@/utils/validate.js';
	import { getYsRegionListApi, getYsChannelListApi, getYsCategoryListApi, getYsBankInfoApi,submitApplyChangeApi } from '@/api/apply.js'
	const app = getApp();
	export default {
		components: {
			"jyf-parser": parser
		},
		data() {
			return {
				loading: false,
				merchantData: JSON.parse(this.$Cache.get('applyInfo')),
				shopApplyType: [
					{name: '个体工商商户', value: 3},
					{name: '企业', value: 4},
				],
				shopApplyTypeIndex: 0,	//开户类型索引
				shopApplyTypeValue: 3,	//开户类型；
				shopApplyTypeName: '个体工商商户',
				busDate: [
					{name: '一年', value: 1},
					{name: '十年', value: 10},
					{name: '二十年', value: 20},
					{name: '三十年', value: 30},
					{name: '长期', value: 0},
				],
				certDate: [
					{name: '五年', value: 5},
					{name: '十年', value: 10},
					{name: '二十年', value: 20},
					{name: '长期', value: 0},
				],
				addressStr: '请选择',	//营业地址&现居住地址
				busCertBgn: '请选择',	//营业执照有效期
				busCertExpire: '请选择',
				certBgn: '请选择',	//身份证有效期
				certExpire: '请选择',
				ysProvince: [],
				ysCity: [],
				ysArea: [],
				ysIndex: [0,0,0],
				ysRegionShow: false,
				standByShow: false,
				stlAccTypeNm: '请选择',
				standByStlAccTypeNm: '请选择',
				accTypes: [
					{name: '对私', value: 11},
					{name: '对公', value: 21},
					{name: '对公存折', value: 23},
					{name: '单位结算卡', value: 24},
				],
				ysChannelList: [],
				ysCategoryList: [],
				ysTypeIndex: [0,0],
				ysTypeShow: false,
				uncrpSett: false,
				isLoading: false,
				theme: app.globalData.theme,
			};
		},
		computed: {
			...mapGetters(['isLogin', 'merchantClassify', 'merchantType']),
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		mounted() {
			this.getYsProvince();
			this.getChannelList();
		},
		onShow() {
			if (!this.isLogin) {
				toLogin();
			}
			let that = this;
			uni.$on('returnData',function(data){
				console.log(data);
				that.merchantData.bankSubCode = data.bankCode;
				that.merchantData.bankSubName = data.bankName;
				if(that.merchantData.bank==null||that.merchantData.bank=="null"){
					that.merchantData.bank = data.bankName.split("行")[0] + "行";
				}
			});
			uni.$on('returnsStandData',function(data){
				console.log(data);
				that.merchantData.standByBankSubCode = data.bankCode;
				that.merchantData.standByBankName = data.bankName;
				if(that.merchantData.standByBankName==null||that.merchantData.standByBankName=="null"){
					that.merchantData.standByBankName = data.bankName.split("行")[0] + "行";
				}
			});
			//#ifdef H5
			uni.$on('upgrade',function(data){
				console.log(data);
				that.$set(that.merchantData, 'busAddr', data.address);
				that.$set(that.merchantData, 'lat', data.location.lat);
				that.$set(that.merchantData, 'lon', data.location.lng);
			});
			//#endif
		},
		onLoad(options) {
			
		},
		methods: {
			bindPickerType: function(e) {//开户类型
				let idx = e.target.value;
				this.shopApplyTypeIndex = idx;
				this.shopApplyTypeValue = this.shopApplyType[idx].value;
				this.shopApplyTypeName = this.shopApplyType[idx].name;
				this.merchantData.mercType = this.shopApplyType[idx].value;
			},
			bindPickerBusBgn: function(e) {//营业执照开始日期
				this.busCertBgn = e.target.value;
				var reg1 = new RegExp("-","g");
				this.merchantData.busCertBgn = e.target.value.replace(reg1, "");
				//重置
				this.busCertExpire = "请选择";
				this.merchantData.busCertExpire = '';
			},
			bindPickerBusEnd: function(e) {//营业执照结束日期
				let idx = e.target.value;
				let value = this.busDate[idx].value;
				if(value>0){
					if(this.busCertBgn==''||this.busCertBgn=='请选择'){
						return uni.showToast({
							icon: 'none',
							title: '请选择营业执照开始有效期',
							duration: 2000
						});
					}
					this.busCertExpire = this.dateFormat(value, this.busCertBgn);
					var reg1 = new RegExp("-","g");
					this.merchantData.busCertExpire = this.busCertExpire.replace(reg1, "");
				}else{
					this.busCertExpire = "长期";
					this.merchantData.busCertExpire = "29991221";
				}		
			},
			bindPickerBgn: function(e) {//身份证有效期开始
				this.certBgn = e.target.value;
				var reg1 = new RegExp("-","g");
				this.merchantData.certBgn = e.target.value.replace(reg1, "");
				//重置
				this.certExpire = "请选择";
				this.merchantData.certExpire = '';
			},
			bindPickerEnd: function(e) {//身份证有效期结束
				let idx = e.target.value;
				let value = this.certDate[idx].value;
				if(value>0){
					if(this.certBgn==''||this.certBgn=='请选择'){
						return uni.showToast({
							icon: 'none',
							title: '请选择身份证开始有效期',
							duration: 2000
						});
					}
					this.certExpire = this.dateFormat(value, this.certBgn);
					var reg1 = new RegExp("-","g");
					this.merchantData.certExpire = this.certExpire.replace(reg1, "");
				}else{
					this.certExpire = "长期";
					this.merchantData.certExpire = "29991231";
				}		
			},
			bindPickerCity: function(e) {//营业地址&现居住地址
				let that = this;
				that.merchantData.busProviceCode = e.detail.code[0];
				that.merchantData.busProviceName = e.detail.value[0];
				that.merchantData.busCityCode = e.detail.code[1];
				that.merchantData.busCityName = e.detail.value[1];
				that.merchantData.busAreaCode = e.detail.code[2];
				that.merchantData.busAreaName = e.detail.value[2];
				that.addressStr = that.merchantData.busProviceName + that.merchantData.busCityName + that.merchantData.busAreaName;
			},
			bindPickerStlAccType: function(e) {//结算类型
				let idx = e.target.value;
				this.merchantData.stlAccType = this.accTypes[idx].value;
				this.stlAccTypeNm = this.accTypes[idx].name;
			},
			bindPickerStandByStlAccType: function(e) {//备用结算类型
				let idx = e.target.value;
				this.merchantData.standByStlAccType = this.accTypes[idx].value;
				this.standByStlAccTypeNm = this.accTypes[idx].name;
			},
			bindChangeYsRegion: function(e) {//开户行地址-列表变更
				let that = this;
				let idxs = e.target.value;
				if(idxs[0]!=that.ysIndex[0]){
					that.ysIndex[0] = idxs[0];
					that.ysIndex[1] = 0;
					that.ysIndex[2] = 0;
					that.ysCity = [];
					that.ysArea = [];
					that.getYsCity(that.ysProvince[idxs[0]]);
					return;
				}
				if(idxs[1]!=that.ysIndex[1]){
					that.ysIndex[1] = idxs[1];
					that.ysIndex[2] = 0;
					that.ysArea = [];
					that.getYsArea(that.ysCity[idxs[1]]);
					return;
				}
				if(idxs[2]!=that.ysIndex[2]){
					that.ysIndex[2] = idxs[2];
				}
			},
			checkYsRegion: function() {//开户行地址-确认选择
				let that = this;
				if(that.standByShow){
					//开户行地址
					that.merchantData.standByBankProvince = that.ysProvince[that.ysIndex[0]].cityCd;
					that.merchantData.standByBankCity = that.ysCity[that.ysIndex[1]].cityCd;
					that.merchantData.standByBankArea = that.ysArea[that.ysIndex[2]].cityCd;
					that.merchantData.standByBankAddress = that.ysProvince[that.ysIndex[0]].cityNm + that.ysCity[that.ysIndex[1]].cityNm + that.ysArea[that.ysIndex[2]].cityNm;
				}else if(that.addressShow){
					//营业地址
					that.merchantData.busProviceCode = that.ysProvince[that.ysIndex[0]].cityCd;
					that.merchantData.busProviceName = that.ysProvince[that.ysIndex[0]].cityNm;
					that.merchantData.busCityCode = that.ysCity[that.ysIndex[1]].cityCd;
					that.merchantData.busCityName = that.ysCity[that.ysIndex[1]].cityNm;
					that.merchantData.busAreaCode = that.ysArea[that.ysIndex[2]].cityCd;
					that.merchantData.busAreaName = that.ysArea[that.ysIndex[2]].cityNm;
					that.addressStr = that.merchantData.busProviceName + that.merchantData.busCityName + that.merchantData.busAreaName;
				}else{
					//备用
					that.merchantData.bankProvince = that.ysProvince[that.ysIndex[0]].cityCd;
					that.merchantData.bankCity = that.ysCity[that.ysIndex[1]].cityCd;
					that.merchantData.bankArea = that.ysArea[that.ysIndex[2]].cityCd;
					that.merchantData.bankAddress = that.ysProvince[that.ysIndex[0]].cityNm + that.ysCity[that.ysIndex[1]].cityNm + that.ysArea[that.ysIndex[2]].cityNm;
				}
				that.standByShow = false;
				that.ysRegionShow = false;
			},
			bindChangeYsType: function(e) {//店铺类型列表
				let that = this;
				let idxs = e.target.value;
				if(idxs[0]!=that.ysTypeIndex[0]){
					that.ysTypeIndex[0] = idxs[0];
					that.ysTypeIndex[1] = 0;
					that.ysCategoryList = [];
					that.getCategoryList(that.ysChannelList[idxs[0]].channelId);
					return;
				}
				if(idxs[1]!=that.ysTypeIndex[1]){
					that.ysTypeIndex[1] = idxs[1];
				}
			},
			checkYsType: function() {//确认选择店铺类型
				let that = this;
				that.merchantData.channelId = that.ysChannelList[that.ysTypeIndex[0]].channelId;
				that.merchantData.mchTypeNm = that.ysChannelList[that.ysTypeIndex[0]].name;
				that.merchantData.mccCd = that.ysCategoryList[that.ysTypeIndex[1]].firstCategory.categoryId;
				that.merchantData.mercClsNm = that.ysCategoryList[that.ysTypeIndex[1]].firstCategory.categoryName;
				that.ysTypeShow = false;
			},
			checkBankNo: function() {//银行卡校验
				let that = this;
				if(that.merchantData.bankAddress==null || that.merchantData.bankAddress==''){
					that.$util.Tips({
						title: '请选择开户行地址'
					});
					return;
				}
				if(that.merchantData.stlAccNo==null || that.merchantData.stlAccNo==''){
					that.$util.Tips({
						title: '请填写银行卡号'
					});
					return;
				}
				getYsBankInfoApi({bankCardNo: that.merchantData.stlAccNo}).then(res =>{
					let data = res.data;
					that.merchantData.bank = data.bankName;
					uni.navigateTo({
						url : '/pages/users/bankSelect/bankSelect?cityCode=' + that.merchantData.bankCity + '&bankType=' + data.minBanktype + '&type=0'
					});
				});
			},
			checkStandBankNo: function() {//备用银行卡校验
				let that = this;
				if(that.merchantData.standByBankAddress==null || that.merchantData.standByBankAddress==''){
					that.$util.Tips({
						title: '请选择备用开户行地址'
					});
					return;
				}
				if(that.merchantData.standByStlAccNo==null || that.merchantData.standByStlAccNo==''){
					that.$util.Tips({
						title: '请填写备用银行卡号'
					});
					return;
				}
				getYsBankInfoApi({bankCardNo: that.merchantData.standByStlAccNo}).then(res =>{
					let data = res.data;
					that.merchantData.standByBank = data.bankName;
					uni.navigateTo({
						url : '/pages/users/bankSelect/bankSelect?cityCode=' + that.merchantData.bankCity + '&bankType=' + data.minBanktype + '&type=1'
					});
				});
			},
			formSubmit: Debounce(function(e) {//下一步		
				uni.showLoading({
					title: '申请提交中...'
				});
				if (!this.isLoading && this.validateForm()) {
					this.isLoading = true;
					submitApplyChangeApi({userYsEntity: this.merchantData}).then(res =>{
						if(res.code==200){
							let data = res.data;
							Cache.set("upgradeInfo", data);
							
							uni.navigateTo({
								url: 'upgradeImage'
							});
							this.isLoading = false;
							uni.hideLoading();
						}else{
							uni.showToast({
								title: res.message
							});
							this.isLoading = false;
						}
					});
				}
			}),
			validateForm: function() {//输入校验
				let that = this,
					value = that.merchantData,
					validate = false;
			
				if(that.shopApplyTypeValue==3||that.shopApplyTypeValue==4){
					if (!value.mercName) return that.$util.Tips({
						title: this.$t(`请填写商户名称`)
					});
					if (value.mercName.length>20&&!value.mercShortName) return that.$util.Tips({
						title: this.$t(`请填写商户简称`)
					});
					if (!value.busNm) return that.$util.Tips({
						title: this.$t(`请填写营业执照名称`)
					});
					if (!value.busNo) return that.$util.Tips({
						title: this.$t(`请填写统一社会信用代码`)
					});
					if (!value.busCertBgn) return that.$util.Tips({
						title: this.$t(`请选择营业执照开始有效期`)
					});
					if (!value.busCertExpire) return that.$util.Tips({
						title: this.$t(`请选择营业执照结束有效期`)
					});
					if (!value.busCertExpire) return that.$util.Tips({
						title: this.$t(`请选择营业执照结束有效期`)
					});
					if (!value.mchTypeNm) return that.$util.Tips({
						title: this.$t(`请选择店铺类型`)
					});
					if (!value.contactMan) return that.$util.Tips({
						title: this.$t(`请填写联系人姓名`)
					});
					if (!value.contactPhone) return that.$util.Tips({
						title: this.$t(`请填写联系人电话`)
					});
					if (!that.addressStr) return that.$util.Tips({
						title: this.$t(`请选择营业地址`)
					});
					//详细地址，地图经纬度
					if (!value.lat) return that.$util.Tips({
						title: this.$t(`请选择地图所在位置`)
					});
					if (!value.busAddr) return that.$util.Tips({
						title: this.$t(`请填写详细地址`)
					});
					if (!value.crpNm) return that.$util.Tips({
						title: this.$t(`请填写身份证姓名`)
					});
					if (!value.crpCertNo) return that.$util.Tips({
						title: this.$t(`请填写身份证号码`)
					});
					if (!value.certBgn) return that.$util.Tips({
						title: this.$t(`请选择身份证有效期开始日期`)
					});
					if (!value.certExpire) return that.$util.Tips({
						title: this.$t(`请选择身份证有效期结束日期`)
					});
					if (!value.bankAddress) return that.$util.Tips({
						title: this.$t(`请选择开户行地址`)
					});
					if (!value.stlAccNm) return that.$util.Tips({
						title: this.$t(`请填写结算户名`)
					});
					if (!value.stlAccNo) return that.$util.Tips({
						title: this.$t(`请填写银行卡号`)
					});
					if (!value.bank) return that.$util.Tips({
						title: this.$t(`请校验银行信息，并选择支行信息`)
					});
					if (!value.bankSubName) return that.$util.Tips({
						title: this.$t(`请校验银行信息，并选择支行信息`)
					});
					if (!value.stlAccType) return that.$util.Tips({
						title: this.$t(`请选择结算账户类型`)
					});
					if(that.uncrpSett){
						if (!value.bankMobile) return that.$util.Tips({
							title: this.$t(`请填写银行预留手机号`)
						});
						if (!value.openCertNo) return that.$util.Tips({
							title: this.$t(`请填写开户证件号`)
						});
						if (!value.standByStlAccNm) return that.$util.Tips({
							title: this.$t(`请填写备用结算户名`)
						});
						if (!value.standByBankAddress) return that.$util.Tips({
							title: this.$t(`请选择备用开户行地址`)
						});
						if (!value.standByBank) return that.$util.Tips({
							title: this.$t(`请校验银行信息，并选择支行信息`)
						});
						if (!value.standByBankName) return that.$util.Tips({
							title: this.$t(`请校验银行信息，并选择支行信息`)
						});
						if (!value.standByStlAccType) return that.$util.Tips({
							title: this.$t(`请选择结算账户类型`)
						});
					}
					validate = true;
				}
				value.uncrpSett = that.uncrpSett?0:1;
				value.mercType = that.shopApplyTypeValue;
				return validate;
			},
			goToMap(){
				// #ifdef H5
				uni.navigateTo({
					url: '/pages/address/mapAddress/mapAddress?pre=upgrade'
				})
				// #endif
				// #ifdef MP
				uni.chooseLocation({
					success: (res) => {
						console.log('位置名称：' + res.name);
						console.log('详细地址：' + res.address);
						console.log('纬度：' + res.latitude);
						console.log('经度：' + res.longitude);
						this.merchantData.busAddr = res.name;
						this.merchantData.lat = res.latitude;
						this.merchantData.lon = res.longitude;
					}
				});
				// #endif
			},
			getDate(type) {	//获取当前时间yyyy-MM-dd
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				
				if (type === 'start') {
					year = year - 100;
				} else if (type === 'end') {
					year = year;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			dateFormat(x, datex) {//时间计算
				const date = new Date(datex);
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				
				year = year + x;
			
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			getYsProvince(){//获取ys省列表
				let that = this;
				let where = {
					areaLevel: 1,
					parentCityCd: '',
					areaCode: '',
					cityNm: ''
				};
				getYsRegionListApi(where).then(res => {
					let list = res.data.areaInfoList;
					that.ysProvince = list;
					that.getYsCity(that.ysProvince[0]);
				});
			},
			getYsCity(item) {//获取ys城市列表
				let that = this;
				let where = {
					areaLevel: 2,
					parentCityCd: item.cityCd,
					areaCode: item.areaCode,
					cityNm: item.cityNm
				};
				getYsRegionListApi(where).then(res => {
					let list = res.data.areaInfoList;
					that.ysCity = list;
					that.getYsArea(that.ysCity[0]);
				});
			},
			getYsArea(item){//获取ys区县列表
				let that = this;
				let where = {
					areaLevel: 3,
					parentCityCd: item.cityCd,
					areaCode: item.areaCode,
					cityNm: item.cityNm
				};
				getYsRegionListApi(where).then(res => {
					let list = res.data.areaInfoList;
					that.ysArea = list;
				});
			},
			getChannelList(){//获取店铺频道
				let that = this;
				getYsChannelListApi().then(res =>{
					let list = res.data;
					that.ysChannelList = list;
					that.getCategoryList(list[0].channelId);
				});
			},
			getCategoryList(id){//获取店铺类型
				let that = this;
				getYsCategoryListApi({channelId: id}).then(res =>{
					let list = res.data;
					that.ysCategoryList = list;
				});
			},
		}
	}
</script>

<style scoped lang="scss">
	.select_code{
		width: 16px;height: 8px;
		display: inline-block;
		margin-left: 16rpx;
	}
	.flag{
		width: 40rpx;
		height:26rpx;
		display: inline-block;
	}
	.uni-input-placeholder {
		color: #B2B2B2;
	}
	.item-name{
		width: 160rpx;
	}
	.merchantsSettled{
		background-color: #F8FBFF;
	}
	.merchantsSettled .list .item {
		padding: 20rpx 40rpx;
		background-color: #fff;
		
		.item-title {
			color: #666666;
			font-size: 28rpx;
			display: block;
		}
		.item-desc {
			color: #B2B2B2;
			font-size: 22rpx;
			display: block;
			margin-top: 9rpx;
			line-height: 36rpx;
		}
		.required{
			display: flex;
			align-items: center;
		}
	}

	.uni-list-cell-db{
		position: relative;
	}
	.merchantsSettled .list .item input {
		width: 470rpx;
		font-size: 30rpx;
		text-align: right;
	}
	.merchantsSettled .list .item .placeholder {
		color: #b2b2b2;
	}
	.merchantsSettled .submitBtn {
		width: 588rpx;
		margin: 25px auto 25px auto;
		height: 86rpx;
		border-radius: 25px;
		text-align: center;
		line-height: 86rpx;
		font-size: 15px;
		color: #fff;
		@include main_bg_color(theme);
	}
	.merchantsSettled .submitBtn.on {
		@include main_bg_color(theme);
	}

	.settledSuccessMain {
		height: 100vh;
		display: flex;
		flex-direction: column;
		background: #fff;
	}
	.settledSuccessful {
		flex: 1;
		width: 100%;
		padding: 0 56px;
		height: auto;
		background: #fff;
		text-align: center;
	}
	.settledSuccessful .image {
		width: 189px;
		height: 157px;
		margin-top: 66px;
	}
	.settledSuccessful .title {
		color: #333333;
		font-size: 16px;
		font-weight: bold;
		margin-top: 35px;
	}
	.settledSuccessful .info {
		color: #A0A0A0;
		font-size: 13px;
		margin-top: 12px;
	}
	.settledSuccessful .goHome {
		margin: 60px auto 0;
		line-height: 43px;
		color: #282828;
		font-size: 15px;
		border: 1px solid #B4B4B4;
		border-radius: 60px;
	}
	.loadingicon {
		height: 100vh;
		overflow: hidden;
		position: absolute;
		top: 0;
		left: 0;
	}
	.icon-xiangyou {
		font-size: 22rpx;
	}
	.required::before {
		content: '* ';
		color: red;
		margin-right: 4rpx;
	}
	.picker-view {
		width: 750rpx;
		height: 500rpx;
		position: fixed;
		bottom: 0;
		z-index: 99 !important;
		background: #fff !important;
		opacity: 1 !important;
		
		.item {
			line-height: 100rpx;
			text-align: center;
		}
	}
	.staorder-overlay{
		width: 100vw;
		height: 100vh;
		position: fixed;
		z-index: 13;
		top: 0;
		left: 0;
		background-color: #000;
		opacity: 0.4;
	}
	.pickerBtn{
		display: flex;
		width: 100vw;
		justify-content: space-between;
		position: fixed;
		bottom: 500rpx;
		z-index: 99 !important;
		background: #fff !important;
		opacity: 1 !important;
		font-size: 36rpx;
		padding: 10rpx 20rpx;
		border-bottom: 1rpx solid #cacaca;
		
		.sure{
			color: #4484FF;
		}
	}
	.checkBtn{
		@include main_bg_color(theme);
		border-radius: 40rpx;
		padding: 6rpx 16rpx;
		margin-left: 20rpx;
		color: #fff;
		width: 100rpx;
	}
</style>
